﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SignInServices.Code;

namespace SignInServices.Admin
{
    public partial class ManageUsers : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var top100Users = SSOFederationHelper.FederationObject.GetUsers(1, 100);
                gvUsers.DataSource = top100Users;
                gvUsers.DataSourceID = "";
                gvUsers.DataBind();
            }
        }

        protected void btnAddNewUser_Click(object sender, EventArgs e)
        {

        }

        protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DoDelete")
            {
                try
                {
                    string un = (string)e.CommandArgument;
                    SSOFederationHelper.FederationObject.DeleteUser((string)e.CommandArgument);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            if (e.CommandName == "DoEdit")
            {
                try
                {
                    // ToDo: must be completed. Only use "SSOFederationHelper.FederationObject" to access the user management services.
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
    }
}